# 这里将用于我测试
# 我在对POST请求进行方法封装时，无法返回一个结果
# 我得到一个数组，而不是直接获取一个对象，因此需要拿到数组再通过键值对取值
require './http.rb'
require './const.rb'
require 'typeprof'
require 'json'
require 'roo'
require 'write_xlsx'

def refund
    return "this is return function of easy!"
end
puts refund
# data = requestPost({ "regex" => "M3190", "status" => 5, "business_type" => false },'POST',Url,Token)
# puts data[0]["merchant_id"]

# test judge brank array 
arr = []
obj = {"code":116,"msg":"sign_three_completed"}
puts JSON.parse(obj.to_json)
# puts obj["code"]
# if arr = []
#     puts "success"
# else puts "fails"
# end
#　这里用于test roo 库 写入Excel表格的操作
# 创建 Excel 文件
# xlsx = Roo::Excelx.new('./test.xlsx')
# # 选择要写入的工作表，默认为第一个工作表（下标为 0）
# xlsx.default_sheet = xlsx.sheets.first
# # 在指定单元格写入数据
# xlsx.set(2, 1, 'Hello')
# xlsx.set(2, 2, 'World')
# # puts xlsx.cell('A',1)
# # 保存文件
# xlsx.close
# data.each_with_index do |row, row_index|
#   row.each_with_index do |cell, col_index|
#     worksheet.write(row_index, col_index, cell)
#   end
# end
# xlsx 写入
require 'write_xlsx'
# Create a new Excel workbook
workbook = WriteXLSX.new('test.xlsx')
# Add a worksheet
worksheet = workbook.add_worksheet
#  Add and define a format
format = workbook.add_format
format.set_bold
format.set_color('red')
format.set_align('center')
# Write a formatted and unformatted string, row and column notation.
col = row = 0
# worksheet.write(row, col, 'Hi Excel!', format)
# worksheet.write(1, col, 'Hi Excel!')
# Write a number and a formula using A1 notation
# worksheet.write('A3', 1.2345 )
# worksheet.write('A4', '=SIN(PI()/4)')
value1 = 0
while value1<10 do
    worksheet.write(value1,0,value1,format)
    value1 = value1 + 1
end
# Write xlsx file to disk.
workbook.close
# interface test
# request param is params, way, url, token, file = nil
# puts requestPost({ "regex" => "w5893", "status" => 5, "business_type" => false },'POST',Url,Token) == []
# puts putsrequestGet("https://api.pooul.com/web/public/zt_signs/#{merchant_id}/snb_single_token","")
# puts requestPost("",'UPLOAD',"http://127.0.0.1:2222/upload","","C://Users/coffe/Pictures/MIUI05.jpg")
# requestPost("hello",'GET',"http://127.0.0.1:2222","","C://Users/coffe/Pictures/MIUI12.jpg")
puts requestGet("http://127.0.0.1:9292","")
# requestPost(params, way, url, token, file = nil)
# Media_types = ['application/json','application/x-www-form-urlencoded','multipart/form-data','text/plain']
# puts Media_types[0]
puts requestPost("","GET","http://127.0.0.1:9292","","")

# testup()